package io.github.wangtianruipopo.cardsdoudizhu.types;

import io.github.wangtianruipopo.cardsdoudizhu.enums.PlayCardsTypeEnum;
import io.github.wangtianruipopo.cardsdoudizhu.impl.DouDiZhuCard;
import io.github.wangtianruipopo.cardsdoudizhu.impl.DouDiZhuPlayCardsType;
import io.github.wangtisnruipopo.carscore.types.ICode;

import java.util.List;

public class PairsPlayCardsType extends DouDiZhuPlayCardsType {
    @Override
    public ICode getType() {
        return PlayCardsTypeEnum.PAIRS;
    }

    @Override
    public boolean valid(List<DouDiZhuCard> cards) {
        // 如果卡牌集合不是两张，则不是对子
        if (cards == null || cards.size() != 2) return false;
        // 如果是两张，则判断两张牌的值是否一样
        DouDiZhuCard card1 = cards.get(0);
        DouDiZhuCard card2 = cards.get(1);
        return card1.getValue().equals(card2.getValue());
    }
}
